/*
https://leetcode-cn.com/problems/container-with-most-water/solution/sheng-zui-duo-shui-de-rong-qi-by-leetcode-solution/
 */
public class Solution11 {
    public int maxArea(int[] height) {
        int l=0,r=height.length-1;
        int ans=0;
        while (l<r){
            ans=Math.max(ans,(r-l)*Math.min(height[l],height[r]));
            if (height[l]<height[r]){
                l++;
            }else{
                r--;
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution11().maxArea(new int[]{1,8,6,2,5,4,8,3,7}));
    }
}
